addEvent(window, 'load', hide_other);
var other_index = 0;
var type_field;
var other_field;

function change_handler()
{
    if (type_field.selectedIndex == other_index) {
        other_field.style.display = ''
    } else {
        other_field.style.display = 'none'
    }
}


function hide_other()
{
    other_field = document.getElementById('id_other_workout_type');
    other_field.style.display = 'none'

    labels = other_field.parentNode.getElementsByTagName('label');
    for (var i = 0; i < labels.length; i++) {
        if (labels[i].getAttribute('for') == 'id_other_workout_type') {
            labels[i].style.display = 'none';
        }
    }

    type_field = document.getElementById('id_workout_type');
    for (i = 0; i < type_field.length; i++) {
        if (type_field.options[i].text == 'Other') {
            other_index = i;
        }
    }
    if (type_field.addEventListener) {
        type_field.addEventListener("change", change_handler, false);
    } else if (type_field.attachEvent) {
        type_field.attachEvent("onchange", change_handler);
    } else {
        type_field.onchange =  change_handler;
    }
}
